package com.alibaba.citrus.ots.platform.enhance.facade.service.scitem.unit;

import java.util.List;

import javax.annotation.Resource;

import com.alibaba.citrus.ots.platform.enhance.functions.item.unit.ScItemUnitEntity;
import com.alibaba.citrus.ots.platform.enhance.repository.ScItemUnitRepository;
import com.alibaba.cz.base.tool.page.PageResult;
import com.alibaba.lattice2.epoch.sdk.model.Result;

import com.epoch.app.otsplatformenhance.api.unit.scitemunitquery.service.ScItemUnitQueryService;
import com.epoch.app.otsplatformenhance.dto.request.IdQueryRequest;
import com.epoch.app.otsplatformenhance.dto.request.QueryScItemUnitRequest;
import com.epoch.app.otsplatformenhance.dto.response.ScItemUnitResponse;
import com.epoch.app.otsplatformenhance.sdo.ScItemUnitSDO;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

/**
 * @author zls
 * @description: TODO
 * @date 2021/9/7 15:30
 */
@Primary
@Service
public class ScItemUnitQueryServiceImpl implements ScItemUnitQueryService {

    @Resource
    ScItemUnitRepository scItemUnitRepository;

    @Override
    public Result<ScItemUnitResponse> getScItemUnit(IdQueryRequest request) {

        System.out.println("入参=="+request);
        ScItemUnitSDO scItemUnitSDO = new ScItemUnitSDO();
        scItemUnitSDO.setId(request.getId());
        ScItemUnitEntity scItemUnitEntity = ScItemUnitEntity.of(scItemUnitSDO);
        return Result.success(scItemUnitEntity.doQueryById());
    }

    @Override
    public Result<List<ScItemUnitSDO>> pageQueryScItemUnitList(QueryScItemUnitRequest request) {
        PageResult<List<ScItemUnitSDO>> pageResult = scItemUnitRepository.pageQueryScItemUnitList(request);
        return Result.listSuccess(pageResult.getContent(), pageResult.getTotal());
    }
}
